using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Module.DonVi.Library.DonVi;
using NCS.Library.Components.Providers;

namespace NCS.Module.DonVi.Library.Providers
{
    public abstract class DataAccessProvider
    {
        private static DataAccessProvider objProvider;
        public static DataAccessProvider instance()
        {
            if (objProvider == null)
            {
                DataAccessProviderConfiguration objConfig = DataAccessProviderConfiguration.GetDataAccessProviderConfiguration();
                Provider defaultProvider = (Provider)objConfig.Providers[objConfig.DefaultProvider];
                Provider provider = new Provider(defaultProvider.ProviderName, "NCS.Module.DonVi.Library.Providers." + defaultProvider.ProviderName, defaultProvider.ConnectionString);
                objProvider = (DataAccessProvider)DataAccessProviderFactory.CreateDataAccess(provider);
            }
            return objProvider;
        }

        /// <summary>
        /// Get all data with TrangThai = 1
        /// </summary>
        /// <returns></returns>
        public abstract DataTable GetDonViAvailable();

        /// <summary>
        /// Get all data
        /// </summary>
        /// <returns></returns>
        public abstract DataTable GetAllDonVi();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="iStatus"></param>
        /// <returns>all record that had TrangThai=1</returns>
        public abstract DataTable GetAllDonViFilter(int iStatus);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns>return one object</returns>
        public abstract DonViInfo GetInfo(int id);

        /// <summary>
        /// Set index of record
        /// </summary>
        /// <param name="id"></param>
        /// <param name="index"></param>
        /// <returns>return number of record changes</returns>
        public abstract int SetIndex(int id, int index);

        /// <summary>
        /// Set status 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns>return number of records changes</returns>
        public abstract int SetStatus(int id, bool status);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="objDonViInfo"></param>
        /// <returns>return number of record changes</returns>
        public abstract int CreateDonVi(DonViInfo objDonViInfo);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="objDonViInfo"></param>
        /// <returns>return number of record changes</returns>
        public abstract int UpdateDonVi(DonViInfo objDonViInfo);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns>return number of record changes</returns>
        public abstract int DeleteDonVi(int id);

        /// <summary>
        /// 
        /// </summary>
        /// <returns>return quantity records</returns>
        public abstract int GetCount();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="portalid"></param>
        /// <param name="typevalue"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public abstract DataTable GetDonVi(int parentId, int portalid, string lang);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="lang"></param>
        /// <returns>return all child with id</returns>
        public abstract DataTable GetAllChildByID(int id, string lang);

    }
}
